import Vue from 'vue'
import App from './App'

import ElementUI from 'element-ui'
import VueI18n from 'vue-i18n'
import enLocale from 'element-ui/lib/locale/lang/en'
import zhLocale from 'element-ui/lib/locale/lang/zh-CN'


import en from './lang/en'
import zh from './lang/zh'

Vue.use(VueI18n)


const messages = {
    en: {
        ...en,
        ...enLocale
    },
    zh: {
        ...zh,
        ...zhLocale
    }
}
const i18n = new VueI18n({
    locale: localStorage.getItem('language') || 'zh',
    messages,
})

// Vue.use(ElementUI, { locale, size: 'small' })


Vue.use(ElementUI, {
    i18n: (key, value) => i18n.t(key, value),
    size: 'small'
})


import UserCard from '@/components/message/user/index'
Vue.use(UserCard)
import Preview from '@/components/message/preview/index.js'
Vue.use(Preview)
import LemonIMUI from '@/components/lemon-imui/index.umd.min.js';
import '@/components/lemon-imui/index.css';
Vue.use(LemonIMUI);
import router from './router'

import store from './store'
Vue.use(store);

import Clipboard from 'v-clipboard'
Vue.use(Clipboard)


Vue.config.productionTip = false

import './directive/index'
import '@/permission' // 权限控制

import packageData from '../package.json' // 全局数据
Vue.prototype.$packageData = packageData;

import LemonMessageVoice from "./components/message/messageType/voice";
import LemonMessageVideo from "./components/message/messageType/video";
import LemonMessageWebrtc from "./components/message/messageType/webrtc";
import LemonMessageFile from "./components/message/messageType/file";
import LemonMessageText from "./components/message/messageType/text";
import lemonMessageTransfer from "./components/message/messageType/transfer";

Vue.component(LemonMessageVideo.name, LemonMessageVideo);
Vue.component(LemonMessageVoice.name, LemonMessageVoice);
Vue.component(LemonMessageWebrtc.name, LemonMessageWebrtc);
Vue.component(LemonMessageFile.name, LemonMessageFile);
Vue.component(LemonMessageText.name, LemonMessageText);
Vue.component(lemonMessageTransfer.name, lemonMessageTransfer);


import elClickoutside from './directive/elclickoutside.js'
Vue.directive('elclickoutside', elClickoutside)

import Api from "@/api/index.js"
Vue.prototype.$api = Api

/* eslint-disable no-new */
new Vue({
    el: '#app',
    i18n,
    router,
    store,
    components: { App },
    template: '<App/>'
})